<template>
	<div v-loading="data.mtloading" class="mt-4">
		<el-form :model="data.macinfo" :inline="true" label-position="left" :label-width="language == 'en'? '150':'90'">
			<div class="w-full flex flex-wrap flex-row">
				<div class="w-1/2" v-if="!isField">
					<el-form-item :label="$t('machine.name')+':'" prop="machine_name" class="w-10/12">
						<el-input v-model="data.macinfo.machine_name" :placeholder="$t('message.pleaseEnter')" />
					</el-form-item>
				</div>
				<div class="w-1/2" v-if="!isField">
					<el-form-item :label="$t('machine.number')+':'" prop="machine_serial_number" class="w-10/12">
						<el-input v-model="data.macinfo.machine_serial_number" :placeholder="$t('message.pleaseEnter')" />
					</el-form-item>
				</div>
				<div class="w-1/2" v-if="!isField">
					<el-form-item :label="$t('machine.lang')+':'" prop="lang" class="w-10/12">
						<el-select v-model="data.macinfo.lang" :placeholder="$t('message.pleaseSelect')" clearable filterable>
							<el-option v-for="item of data.language" :key="item.l_id"
								:label="item.l_id + '-' + item.name" :value="item.lang" />
						</el-select>
					</el-form-item>
				</div>
				<div class="w-1/2">
					<el-form-item :label="$t('machine.currencySymbol')+':'" prop="currency" class="w-10/12">
						<el-input v-model="data.macinfo.currency" :placeholder="$t('message.pleaseEnter')" />
					</el-form-item>
				</div>
				<div class="w-1/2" v-if="!isField">
					<el-form-item :label="$t('machine.addMachine.pic')+':'" prop="pic" class="w-10/12">
						<el-select v-model="data.macinfo.pic" :placeholder="$t('message.pleaseSelect')" clearable filterable
							style="width: 94%;">
							<el-option v-for="item of data.imgarr" :key="item.res_id" :label="item.res_id + '-' + item.title" :value="item.file_path" />
						</el-select>
						<el-icon style="width: 6%;" size="20" @click="urlimg(data.macinfo.pic)">
							<Picture />
						</el-icon>
					</el-form-item>
				</div>
				<div class="w-1/2">
					<el-form-item :label="$t('machine.infos.logo')+':'" prop="logo" class="w-10/12">
						<el-select v-model="data.macinfo.logo" :placeholder="$t('message.pleaseSelect')" clearable filterable style="width: 94%;">
							<el-option v-for="item of data.imgarr" :key="item.res_id" :label="item.res_id + '-' + item.title" :value="item.file_path" />
						</el-select>
						<el-icon style="width: 6%;" size="20" @click="urlimg(data.macinfo.logo)">
							<Picture />
						</el-icon>
					</el-form-item>
				</div>
				<div class="w-1/2" v-if="!isField">
					<el-form-item :label="$t('machine.addMachine.pass')+':'" prop="restore_code" class="w-10/12">
						<el-input v-model="data.macinfo.restore_code" :placeholder="$t('message.pleaseEnter')" />
					</el-form-item>
				</div>
				<div class="w-1/2" v-if="!isField">
					<el-form-item :label="$t('machine.machineStatus')+':'" prop="status" class="w-10/12">
						<el-select v-model="data.macinfo.status" :placeholder="$t('message.pleaseSelect')" filterable>
							<el-option :label="$t('public.normal')" :value="1" />
							<el-option :label="$t('public.disable')" :value="2" />
							<el-option :label="$t('public.uphold')" :value="3" />
						</el-select>
					</el-form-item>
				</div>
				<div class="w-1/2" v-if="false" >
					<el-form-item :label="$t('machine.infos.tel')+':'" prop="service_tel" class="w-10/12">
						<el-input v-model="data.macinfo.service_tel" :placeholder="$t('message.pleaseEnter')" />
					</el-form-item>
				</div>
				<div class="w-1/2" v-if="!isField">
					<el-form-item :label="$t('machine.addMachine.location')+':'" prop="country" class="w-10/12">
						<el-cascader v-model="data.macinfo.country" :props="propsinfo" class="w-full" filterable clearable :placeholder="data.macinfo.address || $t('message.pleaseSelect')" @change="changeCascader" />
					</el-form-item>
				</div>
				<div class="w-1/2" v-if="!isField">
					<el-form-item :label="$t('machine.infos.address')+':'" prop="street" class="w-10/12">
						<el-input v-model="data.macinfo.street" :placeholder="$t('message.pleaseEnter')">
						</el-input>
					</el-form-item>
				</div>
				<div class="w-1/2"v-if="!isField">
					<el-form-item :label="$t('machine.infos.street')+':'" prop="floor" class="w-10/12">
						<el-input v-model="data.macinfo.floor" :placeholder="$t('message.pleaseEnter')">
						</el-input>
					</el-form-item>
				</div>
				<div class="w-1/2" v-if="!isField">
					<el-form-item :label="$t('machine.infos.longitude')+':'" prop="lng" class="w-10/12">
						<el-input v-model="data.macinfo.lngLat" :placeholder="isLock ? $t('message.pleaseEnter') : ''" style="width: 94%;" :disabled="!isLock">
							<template #append>
								<el-icon :size="20">
									<Lock v-if="!isLock" @click="onLock" />
									<Unlock @click="onUnlock" v-else />
								</el-icon>
							</template>
						</el-input>
						<el-icon style="width: 6%;" size="20" @click="urlimg(data.macinfo.logo)">
							<Location @click="onLocation" />
						</el-icon>
					</el-form-item>
				</div>
				<div class="w-1/2" v-if="!isField">
					<el-form-item :label="$t('machine.infos.postalReg')+':'" prop="zip_code" class="w-10/12">
						<el-input v-model="data.macinfo.zip_code" :placeholder="$t('message.pleaseEnter')" />
					</el-form-item>
				</div>
				<div class="w-1/2" v-if="!isField">
					<el-form-item :label="$t('machine.infos.scene')+':'" prop="scene_id" class="w-10/12">
						<el-select v-model="data.macinfo.scene_id" :placeholder="$t('message.pleaseSelect')" clearable filterable>
							<el-option v-for="item of data.scene" :key="item.id" :label="item.id + '-' + item.name" :value="item.id" />
						</el-select>
					</el-form-item>
				</div>
				<div class="w-1/2" v-if="!isField">
					<el-form-item :label="$t('machine.group')+':'" prop="machine_group_id"  class="w-10/12">
						<el-cascader :placeholder="data.groupString || $t('message.pleaseSelect')" class="w-full" clearable :props="propss" v-model="data.macinfo.machine_group_id" />
					</el-form-item>
				</div>
				<div class="w-1/2" v-if="!isField">
					<el-form-item :label="$t('machine.infos.organiz')+':'" prop="ao_id" class="w-10/12">
						<el-cascader v-model="data.macinfo.ao_id" :props="organinfo" class="w-full" clearable :placeholder="$t('message.pleaseSelect')" />
					</el-form-item>
				</div>
				<div class="w-1/2" v-if="!isField">
					<el-form-item :label="$t('machine.infos.modelNo')+':'" prop="machine_type" class="w-10/12">
						<el-select v-model="data.macinfo.machine_type" :placeholder="$t('message.pleaseSelect')" clearable filterable>
							<el-option v-for="item of data.machineTypeList" :key="item.value" :label="item.label" :value="item.value" />
						</el-select>
					</el-form-item>
				</div>
				<div class="w-1/2" v-if="!isField">
					<el-form-item :label="$t('machine.addMachine.mac')+':'" prop="mac_address" class="w-10/12">
						<el-input v-model="data.macinfo.mac_address" :placeholder="$t('message.pleaseEnter')" />
					</el-form-item>
				</div>
				<div class="w-1/2" v-if="!isField">
					<el-form-item :label="$t('machine.appType')+':'" prop="lang" class="w-10/12">
						<el-select v-model="data.macinfo.device_type" :placeholder="$t('message.pleaseSelect')" filterable>
							<el-option :label="$t('machine.vending')" :value="1" />
							<el-option :label="$t('machine.store')" :value="2" />
						</el-select>
					</el-form-item>
				</div>
				<div class="w-1/2" v-if="!isField">
					<el-form-item :label="$t('machine.level')+':'" prop="machine_level" class="w-10/12">
						<el-select v-model="data.macinfo.machine_level" :placeholder="$t('message.pleaseSelect')" filterable>
							<el-option :label="$t('machine.StarterEdition')" :value="1" />
							<el-option :label="$t('machine.DeluxeEdition')" :value="2" />
						</el-select>
					</el-form-item>
				</div>
				<div class="w-1/2" v-if="false">
					<el-form-item :label="$t('machine.addMachine.admin')+':'" prop="manager_id" class="w-10/12">
						<el-select v-model="data.macinfo.manager_id" :placeholder="$t('message.pleaseSelect')" clearable filterable>
							<el-option v-for="item of data.manager" :key="item.manager_id" :label="item.manager_id + '-' + item.nickname" :value="item.manager_id" />
						</el-select>
					</el-form-item>
				</div>
				<div class="w-1/2" v-if="false">
					<el-form-item :label="$t('machine.infos.tallyClerk')+':'" prop="tally_clerk" class="w-10/12">
						<el-select v-model="data.macinfo.tally_clerk" :placeholder="$t('message.pleaseSelect')" clearable filterable>
							<el-option v-for="item of data.manager" :key="item.manager_id" :label="item.manager_id + '-' + item.nickname" :value="item.manager_id" />
						</el-select>
					</el-form-item>
				</div>
				<div class="w-1/2" v-if="!isField">
					<el-form-item :label="$t('machine.addMachine.factory')+':'" prop="mac_address" class="w-10/12">
						<el-input v-model="data.macinfo.factory" :placeholder="$t('message.pleaseEnter')" />
					</el-form-item>
				</div>
				<div class="w-1/2" v-if="!isField">
					<el-form-item :label="$t('machine.addMachine.inventory_location')+':'" prop="mac_address" class="w-10/12">
						<el-input v-model="data.macinfo.inventory_location" :placeholder="$t('message.pleaseEnter')" />
					</el-form-item>
				</div>
				<div class="w-full">
					<el-form-item :label="$t('machine.addMachine.desc')+':'" prop="desc">
						<Editor v-model="data.macinfo.desc" />
					</el-form-item>
				</div>
				<div class="w-full text-center">
					<div class="inline-block" v-if="!isField">
						<el-button v-prmis="'machine_update'" type="primary" size="small" @click="submit">
							<template #default>
								<span class="text-sm">{{ $t('public.save')}}</span>
							</template>
						</el-button>
						<el-button size="small" @click="cancell">
							<template #default>
								<span class="text-sm">{{ $t('public.cancel')}}</span>
							</template>
						</el-button>
					</div>
					<div class="inline-block" v-else>
						<el-button v-prmis="'machine_update'" type="primary" size="small" @click="submitLang">
							<template #default>
								<span class="text-sm">{{ $t('public.save')}}</span>
							</template>
						</el-button>
						<el-button size="small" @click="delLang">
							<template #default>
								<span class="text-sm">{{ $t('public.del')}}</span>
							</template>
						</el-button>
					</div>
				</div>
			</div>
		</el-form>
		<el-dialog v-model="isLocation" center width="50%" :title="$t('machine.infos.map')">
			<div>
				<el-form-item :label="$t('machine.infos.address')+':'" prop="street" class="w-8/12">
					<!-- @keyup.enter="handleEnter" -->
					<el-input v-model="center.address" :placeholder="$t('message.pleasetoEnter')" :disabled="isLock" @keyup.enter="handleEnter">
					</el-input>
				</el-form-item>
				<el-form-item :label="$t('machine.infos.lon')+':'" prop="street" class="w-8/12">
					<el-input v-model="center.lng" :placeholder="$t('message.pleaseEnter')" :disabled="!isLock">
					</el-input>
				</el-form-item>
				<el-form-item :label="$t('machine.infos.lat')+':'" prop="street" class="w-8/12">
					<el-input v-model="center.lat" :placeholder="$t('message.pleaseEnter')" :disabled="!isLock">
					</el-input>
				</el-form-item>
			</div>
			<div id="mapCenter" :ref="mapRef" style="width: 100%; height: 400px;">
			</div>
			<div class="pt-6 text-center">
				<el-button type="primary" size="small" @click="onOk">
					{{ $t('public.ok')}}
				</el-button>
				<el-button size="small" @click="cancell">
					{{ $t('public.cancel')}}
				</el-button>
			</div>
		</el-dialog>
	</div>
</template>

<script lang="ts" setup>
import { useI18n } from 'vue-i18n' 
const { t: $t } = useI18n()
import { getlist } from '@/utils/earth';
import { getresourceList } from '@/api/advment';
import { getlang, getscene } from '@/api/manage';
import { getgroupList, getListgroupmg } from '@/api/machine_type';
import { getmanagerList } from '@/api/manager';
import Editor from '@/components/Editor/index.vue';
import arrange from '@/utils/hierarchy';
import { useRouter } from "vue-router";
import { getAddress, getLocation,gettLocations } from '@/api/map'
import { ref, nextTick, onMounted } from 'vue';
import { deltLang } from "@/api/machine";
const { locale } = useI18n()
let language = ref()
const TMap = (window as any).TMap;
const mapRef = ref();
let isLocation = ref(false)
let isLock = ref(false)
const router = useRouter()
let center = ref({ lng: null, lat: null, location: '', address: '' })
let emit = defineEmits(['investigate','submitLang','delLang'])
let props = defineProps({
	info: {
		type: Object,
		default: {}
	},
	machineLangList: {
		type: Array,
		default:[] 
	},
	isField:{
		type: Boolean,
		default: true
	}
})
let idArr = ref([])
let data = reactive({
	groupString:'',
	data: [],
	mtloading: false, // 加载
	demonstrate: false, // 图片弹窗
	language: [], // 设备语言
	imgarr: [], // 设备图片
	scene: [], // 设备场景
	manager: [], // 管理员列表
	mactype: [], // 设备分组
	macinfo: {}, // 设备主体信息
	file_path: '', // 图片地址,
	machineTypeList: [{ value: 1, label: '001' }, { value: 2, label: '002' }, { value: 3, label: '003' }, { value: 4, label: '004' }, { value: 5, label: '005' }]
})
onMounted(() => {
    language.value = locale.value
})
watchEffect(()=>{
		if(props.machineLangList.length){
			data.macinfo.logo = props.machineLangList[0].logo
			data.macinfo.currency = props.machineLangList[0].currency
			data.macinfo.desc = props.machineLangList[0].desc
		}
		else{
			data.macinfo.logo = ''
			data.macinfo.currency = ''
			data.macinfo.desc = ''
		}
})

// 管理组织
let organinfo = reactive({
	lazy: true,
	multiple: false,
	emitPath: true,
	checkStrictly: true,
	async lazyLoad(node: any, resolve: any) {
		let nodes = await arrange.arrange(2, node.data.value);
		resolve(nodes);
	}
});
const propss = reactive(
	{
		checkStrictly: true,
		lazy: true,
		multiple: true,
		async lazyLoad(node:any, resolve:any) {
			const { level, value } = node
			let nodes = await getgroupList({pid:value});
			if (nodes.state == 100 || nodes.state == 300) {
				resolve([]);
			}
			const nodesa = nodes.data.map((item) => ({
				value: item.mg_id,
				label: item.mg_id + '-' + item.mg_name
			}))
			resolve(nodesa);
		}
	}
)
let changeCascader = (valueArr) => {
	// data.macinfo.lngLat = ''
	data.macinfo.street = ''
	data.macinfo.floor = ''
	getlist({}, 0 + 2).then(res => {
		if (res.length) {
			let id1 = res.filter(ite => valueArr[0] == ite.value)
			if (id1.length) {
				idArr.value.push(id1[0])
			}
			getlist(id1[0].value, 1 + 2).then(res => {
				if (res.length) {
					let id2 = res.filter(ite => valueArr[1] == ite.value)
					if (id2.length) {
						idArr.value.push(id2[0])
					}
					getlist(id2[0].value, 2 + 2).then(res => {
						if (res.length) {
							let id3 = res.filter(ite => valueArr[2] == ite.value)
							if (id3.length) {
								idArr.value.push(id3[0])
							}
							getlist(id2[0].value, 3 + 2).then(res => {
								if (res.length) {
									let id4 = res.filter(ite => valueArr[3] == ite.value)
									if (id4.length) {
										idArr.value.push(id4[0])
									}
								}
							})
						}
					})
				}
			})
		}
	})
}
let delLang = () => {
	deltLang({ ml_id: props.machineLangList[0].ml_id }).then((res) => {
	data.macinfo.logo = ''
	data.macinfo.currency = ''
	data.macinfo.desc = ''
	emit('delLang')
    ElMessage({
      message: $t("message.delSuccess"),
      type: "success",
    });
  });
};
let submitLang = ()=>{
	let parm ={
		logo: data.macinfo.logo,
		currency: data.macinfo.currency,
		desc:data.macinfo.desc
	}
	// 添加
	if(!props.machineLangList.length){
		emit('submitLang', parm, 1)
	}
	// 编辑
	if(props.machineLangList.length && props.machineLangList[0].ml_id){
		emit('submitLang', parm, 2)
	}
}
let onUnlock = () => {
	isLock.value = false
}
let onLock = () => {
	isLock.value = true
}
let onOk = () => {
	isLocation.value = false
	data.macinfo.lngLat = `${center.value.lng},${center.value.lat}`
}
let userlocation: any = {
	map: "",
	markerLayer: "",
	lng: "",
	lat: "",
};
//标记地图
let markerLayer = (lng, lat) => {	
	new TMap.MultiMarker({
		map:userlocation.map, //指定地图容器
		//样式定义
		styles: {
			myStyle: new TMap.MarkerStyle({
				anchor: { x: 16, y: 32 },
			}),
		},
	
		//点标记数据数组
		geometries: [
			{
				id: "1", //点标记唯一标识，后续如果有删除、修改位置等操作，都需要此id
				styleId: "myStyle", //指定样式id
				position: new TMap.LatLng(lng,lat), //点标记坐标位置
			},
		],
	});
}
const handleEnter = () => {
	if (!isLock.value && center.value.address) {
		findAddr(center.value.address)
	}
};
let findMap = async () => {
	let center = new TMap.LatLng(39.984120, 116.307484);
	userlocation.map = new TMap.Map("mapCenter", {
		center: center,
		zoom: 11,
		pitch: 0, // 俯仰度
		rotation: 0, // 旋转角度
	})
}
// 根据地址获取坐标
let findAddr = (address: string) => {
	getAddress(address).then(res => {
		// 处理得到的经纬度
		if (!data.macinfo.country.length) {
			data.macinfo.lngLat = `${res.data.result.location.lat},${res.data.result.location.lng}`
		}
		userlocation.lat = res.data.result.location.lat
		userlocation.lng = res.data.result.location.lng
		if (!isLock.value && !data.macinfo.country.length) {
			center.value.address = address
		}
		center.value.lat = res.data.result.location.lat
		center.value.lng = res.data.result.location.lng
		nextTick(() => {
			findMap();
			reloadMap()
			markerLayer(center.value.lat, center.value.lng); // 标记地图
		})
	}).catch(err => {
		console.log(err)
	})

}
// 坐标转地址
let findLocation = (location: string) => {
	getLocation(location).then(res => {
		findAddr(res.data.result.address)
		nextTick(() => {
			findMap();
			reloadMap()
			markerLayer(res.data.result.location.lng, res.data.result.location.lat); // 标记地图
		})
	}).catch(err => {
		console.log(err)
	})
}
// 坐标转地址
let findLocations = (location: string) => {
	gettLocations(location).then(res => {
		let len= res.data.result.locations[0].lng+','+ res.data.result.locations[0].lat
		findLocation(len)
		nextTick(() => {
			findMap();
			reloadMap()
			markerLayer(res.data.result.locations[0].lng, res.data.result.locations[0].lat); // 标记地图
		})
	}).catch(err => {
		console.log(err)
	})
}
// 重载地图
let reloadMap = () => {
	(document.getElementById("mapCenter") as any).innerHTML = null;
	userlocation.markerLayer = "";
	let center = new (window as any).TMap.LatLng(userlocation.lat, userlocation.lng);
	userlocation.map = new (window as any).TMap.Map(document.getElementById("mapCenter"), {
		center: center, //设置地图中心点坐标
		viewMode: "3D",
	});
}
let onLocation = () => {
	isLocation.value = true
	if (!data.macinfo.lngLat) {
		center.value.lng = ''
		center.value.lat = ''
		center.value.address = ''
	} else {
		let arr = data.macinfo.lngLat.split(',')
		center.value.lng = arr[0]
		center.value.lat = arr[1]
		findLocation(data.macinfo.lngLat)
		findLocations(data.macinfo.lngLat)
	}
}
// 获取列表信息
let getobjlist = async () => {
	// 主体信息
	for (let key in props.info) {
		data.macinfo[key] = props.info[key] || ''
	}
	for (let key in data.macinfo) {
		if (key != 'ao_id') {
			data.macinfo[key] = props.info[key]
		}
	}
	data.macinfo.lngLat = props.info.lng + ',' + props.info.lat
	let infoAddress = ''
	if (props.info.country || props.info.state || props.info.city) {
		let country_cname = props.info.country && props.info.country.code ? props.info.country.cname : ''
		let country_name = props.info.country && props.info.country.code ? `(${(props.info.country.name)})` : ''
		let state_cname = props.info.state && props.info.state.code ? props.info.state.cname : ''
		let state_name = props.info.state && props.info.state.code ? `(${(props.info.state.name)})` : ''
		let city_cname = props.info.code && props.info.city.code ? props.info.city.cname : ''
		let city_name = props.info.code && props.info.city.code ? `(${(props.info.city.name)})` : ''
		infoAddress = country_cname + country_name + state_cname + state_name + city_cname + city_name
	}
	data.macinfo.address = infoAddress
	data.macinfo.ao_id = await arrange.echo(props.info.ao_id)
	data.macinfo.country = []
	data.imgarr = []
	// 素材列表
	getresourceList({ type: 1 }).then(res => {
		if (res.state == 200) {
			for (let item of res.data) {
				if (item.status == 1) {
					data.imgarr.push(item)
				}
			}
		}
	})

	// 语言列表
	getlang().then(res => {
		if (res.state == 200) {
			data.language = res.data
		}
	})

	// 场景列表
	getscene().then(res => {
		if (res.state == 200) {
			data.scene = res.data
		}
	})

	// 管理员列表
	getmanagerList().then(res => {
		if (res.state == 200) {
			data.manager = res.data
		}
	})

	// 设备分组
	// getgroupList().then(res => {
	// 	if (res.state == 200) {
	// 		data.mactype = res.data
	// 	}
	// })

	getListgroupmg({ m_id: data.macinfo.m_id }).then(res => {
		if (res.state == 200) {
			data.macinfo.machine_group_id = []
			let groupString = []
			for (let item of res.data) {
				// data.macinfo.machine_group_id.push(item.mg_id)
				groupString.push(`${item.mg_id}-${item.mg_name}`)
			}
			data.groupString = groupString.join(',')
		}
	})

}

// 查看素材
let urlimg = (e) => {
	if (e == '') {
		return;
	}
	data.demonstrate = true;
	data.file_path = e;
}

// 地理位置
let propsinfo = reactive({
	lazy: true,
	multiple: false,
	emitPath: true,
	checkStrictly: true,
	async lazyLoad(node, resolve) {
		const { level, value } = node
		let nodes = await getlist(value, level + 2)
		if (nodes.state == 100 || nodes.state == 300) {
			resolve([]);
		}
		resolve(nodes);
	}
});

// 保存
let submit = () => {
	let lngLatArr = data.macinfo.lngLat.split(',')
	let machine_group_id_list:any = []
	if (data.macinfo.machine_group_id && data.macinfo.machine_group_id.length > 0) {
		data.macinfo.machine_group_id.forEach(ite=>{
			machine_group_id_list.push(ite[ite.length-1])
		})
	}
	let obj = {
		mac_address: data.macinfo.mac_address,
		machine_type: data.macinfo.machine_type,
		ao_id: data.macinfo.ao_id,
		m_id: data.macinfo.m_id,
		machine_name: data.macinfo.machine_name,
		machine_serial_number: data.macinfo.machine_serial_number,
		pic: data.macinfo.pic,
		logo: data.macinfo.logo,
		lang: data.macinfo.lang,
		currency: data.macinfo.currency,
		restore_code: data.macinfo.restore_code,
		service_tel: data.macinfo.service_tel,
		desc: data.macinfo.desc,
		country_id: data.macinfo.country_id,
		state_id: data.macinfo.state_id,
		city_id: data.macinfo.city_id,
		regions_id: data.macinfo.regions_id,
		zip_code: data.macinfo.zip_code,
		street: data.macinfo.street,
		floor: data.macinfo.floor,
		scene_id: data.macinfo.scene_id,
		lat: lngLatArr[1],
		lng: lngLatArr[0],
		status: data.macinfo.status,
		manager_id: data.macinfo.manager_id,
		tally_clerk: data.macinfo.tally_clerk,
		config_id: data.macinfo.config_id,
		help_ids: data.macinfo.help_ids,
		machine_group_id: machine_group_id_list.join(','),
		device_type: data.macinfo.device_type,
		factory: data.macinfo.factory,
		inventory_location: data.macinfo.inventory_location,
		machine_level: data.macinfo.machine_level
	}
	if (data.macinfo.country != null && data.macinfo.country.length != 0) {
		obj.country_id = data.macinfo.country[0] || ''
		obj.state_id = data.macinfo.country[1] || ''
		obj.city_id = data.macinfo.country[2] || ''
		obj.regions_id = data.macinfo.country[3] || ''
	}
	if (obj.ao_id.length) {
		obj.ao_id = obj.ao_id[obj.ao_id.length - 1]
	}

	emit('investigate', obj)

}

// 取消
let cancell = () => {
	for (let key in props.info) {
		data.macinfo[key] = props.info[key] || ''
	}
	data.macinfo.country = []
	router.back()
}

getobjlist()
</script>
<style scoped>
.map {

	width: 100%;
	height: 300px;
}
</style>